package com.wn.demo01;

import com.wn.common.jwt.JwtTemplate;

import java.util.HashMap;
import java.util.Map;

/**
 * @author yellow Docter
 * @date 2022 -11-08
 * @desc
 *
 *  使用封装的工具
 *
 *     1、校验
 *     2、解析token
 *
 */
public class Demo02 {

    public static void main(String[] args) {

        JwtTemplate jwtTemplate = new JwtTemplate();

        Map<String,Object> map = new HashMap<>();
        map.put("name","hello");
        map.put("tel","123");

        //创建
        String token = jwtTemplate.createToken(map);
        System.out.println("token = " + token);

        // 验证token
        boolean verifyToken = jwtTemplate.verifyToken(token);
        System.out.println("verifyToken = " + verifyToken);


        //解析token
        if (verifyToken) {

            Object name = jwtTemplate.parseToken(token, "name");
            System.out.println("name = " + name);

            Object tel = jwtTemplate.parseToken(token, "tel");
            System.out.println("tel = " + tel);

        }

    }

}
